package ReflectTest;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

/*
反编译一个类属性
 */
public class ReflectFieldTest2 {
    public static void main(String[] args) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            Class c = Class.forName("java.lang.String");
            stringBuilder.append("public class "+c.getSimpleName()+"{");
            Field[] fields = c.getDeclaredFields();
            for(Field field : fields){
                stringBuilder.append("\t");
                stringBuilder.append("\n\t"+Modifier.toString(field.getModifiers())+" "+field.getType().getSimpleName()+" "+field.getName());

            }
            stringBuilder.append("\n}");
            System.out.println(stringBuilder);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
